const filmAndCinemaModel = require('../model/filmAndCinemaModel');
const filmModel = require('../model/filmModel');
const cinemaModel = require('../model/cinemaModel');
module.exports.findAll = async function(){
    return await filmAndCinemaModel.find();
}
module.exports.findByFilmIdAndCinemaId = async function(filmId,cinemaId){
    return await filmAndCinemaModel
                .find({films:filmId,cinemas:cinemaId})
                .populate({path:'films'})
                .populate({path:'cinemas'});
}
module.exports.findByFilmId = async function(filmId){
    return await filmAndCinemaModel
                .find({films:filmId})
                .populate({path:'cinemas'});
}

module.exports.insert = async function(filmAndCinema){
    return await filmAndCinemaModel.create(filmAndCinema);
}
module.exports.update = async function(id,filmAndCinema){
    return await filmAndCinemaModel.updateOne({_id:id},filmAndCinema);
}